package jiazhong.hfl20250308;

import java.util.Stack;

//4.有一个存放学生信息的集合(学生属性：编号、姓名和年龄)，求出比张三年龄大的学生(选作)
public class StudentTest {
    public static void main(String[] args) {
        Student student = new Student();
        Stack<Student> studentStack = new Stack<>();
        student = new Student(1, "张三", 20);
        studentStack.push(student);
        student = new Student(2, "李四", 21);
        studentStack.push(student);
        student = new Student(3, "王五", 22);
        studentStack.push(student);
        student = new Student(4, "王九", 18);
        studentStack.push(student);
        student = new Student(5, "李白", 26);
        studentStack.push(student);
        student = new Student(6, "王麻子", 30);
        studentStack.push(student);
        Integer age = 0;
        for (Student s : studentStack) {
            if (s.getName().equals("张三")) {
                age = s.getAge();
            }
        }
        for (Student s : studentStack) {
            if (s.getAge() > age) {
                System.out.println(s.getId() + " " + s.getName() + " " + s.getAge());
            }
        }
    }
}
